package com.gusto.engine.recommend.prediction;

import org.apache.log4j.Logger;

import com.gusto.engine.colfil.Prediction;
import com.gusto.engine.recommend.PredictionService;
import com.gusto.engine.recommend.prediction.base.BaseImpl;

/**
 * <p>Random prediction algorithm, returns a random value.</p>
 * 
 * @author amokrane.belloui@gmail.com
 *
 */
public class RandomImpl extends BaseImpl implements PredictionService {
	
	private Logger log = Logger.getLogger(getClass());
	
	private Integer min, max;
	
	public void setMin(Integer min) {
		this.min = min;
	}
	public void setMax(Integer max) {
		this.max = max;
	}
	
	/**
	 * {@inheritDoc}
	 */
	public Prediction predict(long userId, long itemId, boolean includePrediction) {
		long start = System.currentTimeMillis();
		
		double pred_val = Math.random() * (max - min) + (min);
		
		log.debug("Random prediction " + pred_val);
		
		Prediction eval = new Prediction(pred_val);
		eval.setUserId(userId);
		eval.setItemId(itemId);
		
		logPrediction(0, 0, 0, (System.currentTimeMillis() - start), "PPPP");
		return eval;
	}
	
}
